package jpavlich.cardsorter;

import java.io.File;
import java.io.FileFilter;
import java.text.DecimalFormat;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

import javax.swing.AbstractListModel;

public abstract class FileListModel extends AbstractListModel {

	protected File[] files = null;

	public int getSize() {
		return getValues().length;
	}

	public Object getElementAt(int index) {
		return getValues()[index];
	}

	public File[] getValues() {
		if (files == null) {
			updateValues();
		}
		return files;

	}

	public void updateValues() {
		File expDir = getBaseFolder();
		if (!expDir.exists()) {
			expDir.mkdirs();
		}
		
		files = expDir.listFiles(getFileFilter());
		fireContentsChanged(this, 0, files.length);
	}

	public abstract  File getBaseFolder();

	protected abstract FileFilter getFileFilter();


}
